﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>手机屏幕显示字段排序 </title>

    <!--引入jquery-->
    <script src="../../Scripts/jquery-1.11.0.min.js"></script>
    <!--引入bootstrap-->
    <link href="../../Scripts/easyUI145/themes/default/easyui.css" rel="stylesheet" type="text/css" />
    <link href="../../Scripts/bootstrap/css/bootstrap.min.css" rel="stylesheet" />
    <script src="../../Scripts/bootstrap/js/bootstrap.min.js"></script>

    <!--引入通用的JS-->
    <script src="../../Scripts/QueryString.js"></script>
    <script src="../../Scripts/config.js"></script>
    <script src="../../Comm/Gener.js"></script>
    <script src="../../Scripts/PinYin.js"></script>
    <script src="../../Scripts/vue.js"></script>
    <link href="../../../../DataUser/Style/ccbpm.css" rel="stylesheet" />
    <script src="./js/ueditor/dialogs/internal.js"></script>
    <script src="../../../../DataUser/JSLibData/CommonShowConfig.js"></script>
    <script src="./DialogCtr/Public.js"></script>
    <script src="../../Scripts/easyUI/jquery.easyui.min.js" type="text/javascript"></script>
    <link href="../../Scripts/bootstrap/bootstrap-table/src/bootstrap-table.css" rel="stylesheet" />
    <style type="text/css">
        .cs-content-box .cs-help ul {
            margin: 0px 0px !important;
        }
    </style>
    <script type="text/javascript">

        var frmID = "";
        var dtGroups = null;
        var mapAttrs = null;
        var handler = new HttpHandler("BP.WF.HttpHandler.WF_Admin_DevelopDesigner");

        $(function () {

            var data = handler.DoMethodReturnString("Template_Init");

            if (data.indexOf('err') >= 0) {

                alert(data);
                return;
            }
            data = JSON.parse(data);
            var dirs = data.dirs;
            var temps = data.temps;

            tempData = temps;

            var dir1ul = "<ul>";

            //var html="<ul>";
            //for (var i = 0; i < data.length; i++) {
            //    var temp = data[i];

            //    html += "<li ><a href=\"javascript:Save('" + temp.OriginalPath + "')\" >" + temp.OriginalPath.replace(".htm", "") + "</a></li>";
            //}
            //html += "</ul>";

            //$("#devTemp").append(html);

            for (var i = 0; i < dirs.length; i++) {
                var dir = dirs[i];
                dir1ul += "<li><img src='../../Img/M2MM.png' />" + dir.Name + "";

                dir1ul += "<ul>";
                for (var k = 0; k < temps.length; k++) {

                    var temp = temps[k];
                    if (temp.Dir == dir.Name)
                        dir1ul += "<li style='padding-left: 24px'><a  href='javascript:Save(\"" + temp.Name + "\",\"" + dir.Name + "\")'><img src='../../Img/ie.gif' />" + temp.Name.replace(".htm", "") + "</a></li>";
                }
                dir1ul += "</ul></li>";
            }
            dir1ul += "</ul>";
            $("#devTemp").html(dir1ul);
        });

        function Save(val, dir) {

            var ctrl = document.getElementById("CB_IsCalearHtml");
            var isClear = ctrl.checked;
            if (ctrl == true) {
                var val = confirm("您确定要清除现有的html插入指定的模版吗？");
                if (val == false)
                    return;
            }

            handler.AddPara("DevTempName", val);
            handler.AddPara("DevTempDir", dir);

            var data = handler.DoMethodReturnString("Template_GenerHtml");

            if (data.indexOf('err') >= 0) {
                alert(data);
                DevForm_Close();
                return;
            }

            if (isClear == true) {
                editor.setContent('');
                editor.execCommand('insertHtml', data);
            }
            else {
                editor.execCommand('insertHtml', data);
            }

            DevForm_Close();
        }
        function DevForm_Close() {
            dialog.close(true);
        }

        function SaveImpFromLocalFile() {
            var fileValue = $("#File_Upload").val();
            //必须要选择文件
            if (fileValue == "") {
                $.messager.alert("提示", "没有选择流程模板。");
                return;
            }
            //扩展名
            var index = fileValue.lastIndexOf('.');
            var fileExt = fileValue.substring(index);
            if (fileExt.toLowerCase() == ".html" || fileExt.toLowerCase() == ".htm" || fileExt.toLowerCase() == ".doc" || fileExt.toLowerCase() == ".docx") {

            } else {
                $.messager.alert("提示", "所选表单模板文件，请重新选择。");
                return;
            }
            $("#form1").form("submit", {
                type: 'POST',
                dataType: 'html',
                url: dynamicHandler + "?DoType=HttpHandler&DoMethod=Template_Imp&HttpHandlerName=BP.WF.HttpHandler.WF_Admin_DevelopDesigner&FK_MapData=" + GetQueryString("FK_MapData"),
                onSubmit: function (param) {
                    //return false;
                },
                success: function (data) {
                    if (data.indexOf('err@') == 0) {
                        alert(data);
                        return;
                    }
                    var ctrl = document.getElementById("CB_IsCalearHtml");
                    var isClear = ctrl.checked;
                   
                    if (isClear == true) {
                        editor.setContent('');
                        editor.execCommand('insertHtml', data);
                    }
                    else {
                        editor.execCommand('insertHtml', data);
                    }

                    DevForm_Close();
                }
            });
        }
    </script>

</head>
<body>
    <form id="form1" name="form1" action="" enctype="multipart/form-data" method="post">
        <div>
            <fieldset>
                <legend>常用模板</legend>
                <ul style="margin:0px">
                    <li><div id="devTemp"></div></li>
                </ul>



            </fieldset>
            <fieldset>
                <legend>引用本地模板</legend>
                <div>
                    <input style="background-color:white;color:#000000;display:inline" type="file" id="File_Upload" name="File_Upload" />
                    <input type="button"  value="执行导入" onclick="SaveImpFromLocalFile();" class="cc-btn-tab" />
                </div>
            </fieldset>

            <fieldset>
                <legend>
                    <input type="checkbox" id="CB_IsCalearHtml" value="1" checked="true" />
                    是否清空已有的html?
                </legend>
                
            </fieldset>
            
            <fieldset>
                <legend id="help"></legend>
                <ul>
                    <li> 所有的模版文件位于 DataUser\Style\TemplateFoolDevelopDesigner\*.htm </li>
                    <li> 如果要维护这些文件，请直接打开该目录进行维护。 </li>
                </ul>
            </fieldset>



        </div>
        <!--<div id="toolbar">
            <h4> 请选择模版：</h4>
        </div>-->




    </form>
    <script src="../Admin.js"></script>
</body>
</html>
